
<?php

require 'dbtool.php';

$key = $_COOKIE["userkey"];
session_start();
$userName = '';
$is_login = false;

$conn = new mysqli();
$conn->connect('127.0.0.1','root','root','bank');
if(!empty($conn->connect_error)){
    echo 'MYSQL数据库连接错误: '.$conn->connect_error;
    die;
}
$sql = 'select RealName from accountinfo WHERE AccountId = (SELECT AccountId from bankcard WHERE CardNo = '.$_SESSION[$key]["username"].')';
dbtool::setconn($conn);
$data = dbtool::selectconn($sql);

if(!isset($_SESSION[$key]["username"])){
    $userName= "你尚未登入，<a href='/login.php'>请登入</a>";
}else{
    $userName =  "欢迎你  ".$data[0]["RealName"];
    $is_login = true;
}

$logUrl =  '../public/image/'.$_GET['log'];

?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<p><?php echo $userName;?>
        <?php if($is_login) {?>
            <br /><a href="logout.php">退出</a></p>
            <a href="changePassword_page.php"><button type="button">修改密码</button></a>
            <p>头像：<img src="<?php echo $logUrl;?>" width="100px" height="100px"></p>

            <form action="img.php" method="post" enctype="multipart/form-data">
                <input type="file" name="file">
                <br/>
                <button type="submit">上传头像</button>
            </form>
        <?php } ?>
	</body>

</html>
